package priv.yiyuan.example.design;

import java.util.List;

/**
 * 宏命令
 * <p>
 * 命令模式(具体命令)
 *
 * @author YiYuan
 * @data 2025/8/20
 * @apoNote
 */
public class MacroCommand implements Command {

    private List<Command> commands;

    public MacroCommand(List<Command> commands) {
        this.commands = commands;
    }

    @Override
    public void execute() {

        for (Command command : commands) {
            command.execute();
        }

    }

    @Override
    public void undo() {
        for (int i = commands.size() - 1; i >= 0; i--) {
            commands.get(i).undo();
        }
    }
}
